package com.ray.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ray.bean.CompanyMaterialTypeBean;
import com.ray.bean.DatatablesViewPageBean;
import com.ray.service.CompanyMaterialTypeService;
import com.ray.util.RequestUtil;
import com.ray.util.ResponseUtil;

/**
 * 公司物料类型配置表(公共物料类型+公司自己添加)
* <p>Title: CompanyMaterialTypeController</p>  
* <p>Description: </p>  
* @author 李斌  
* @date 2018年10月8日
 */
@Controller
@RequestMapping("companyMaterialType")
public class CompanyMaterialTypeController {
	
	@Autowired
	private CompanyMaterialTypeService companyMaterialTypeService;
	
	/**
	 * 获取公司物料类型配置表
	* @date 2018年10月8日 下午2:28:10 
	* @author 李斌
	* @return DatatablesViewPageBean<CompanyMaterialTypeBean> 
	* @throws
	 */
	@RequestMapping("/getCompanyMaterialTypeListByPage")
	@ResponseBody
	public DatatablesViewPageBean<CompanyMaterialTypeBean> getCompanyMaterialTypeListByPage(HttpServletRequest request){
		Map<String,String> map = RequestUtil.getRequestAllParam(request);
		return companyMaterialTypeService.getCompanyMaterialTypeListByPage(map);
	}
	
	/**
	 * 查询物料类型不分页
	 * @param request
	 * @return
	 */
	@RequestMapping("/getCompanyMaterialTypeListData")
	@ResponseBody
	public Map<String,Object> getCompanyMaterialTypeListData(HttpServletRequest request){
		Map<String,String> map = RequestUtil.getRequestAllParam(request);
		return ResponseUtil.ResponseResult(companyMaterialTypeService.getCompanyMaterialTypeListData(map));
	}
	
	/**
	 * 获取所有有效的物料类型名称
	* @date 2018年10月9日 上午10:23:56 
	* @author 李斌
	* @return List<String> 
	* @throws
	 */
	@RequestMapping("/getCompanyMaterialTypeList")
	@ResponseBody
	public Map<String,Object> getCompanyMaterialTypeList(HttpServletRequest request){
		Map<String,String> map = RequestUtil.getRequestAllParam(request);
		return ResponseUtil.ResponseResult(companyMaterialTypeService.getCompanyMaterialTypeList(map));
	}
	
	/**
	 * 获取所有物料类型名称
	 * @param request
	 * @return
	 */
	@RequestMapping("/getAllCompanyMaterialTypeList")
	@ResponseBody
	public Map<String,Object> getAllCompanyMaterialTypeList(HttpServletRequest request){
		Map<String,String> map = RequestUtil.getRequestAllParam(request);
		return ResponseUtil.ResponseResult(companyMaterialTypeService.getAllCompanyMaterialTypeList(map));
	}
	
	/**
	 * 添加物料类型
	* @date 2018年10月9日 上午8:30:30 
	* @author 李斌
	* @return Map<String,Object> 
	* @throws
	 */
	@RequestMapping("/addCompanyMaterialType")
	@ResponseBody
	public Map<String,Object> addCompanyMaterialType(HttpServletRequest request){
		Map<String,String> map = RequestUtil.getRequestAllParam(request);
		companyMaterialTypeService.addCompanyMaterialType(map);
		return ResponseUtil.ResponseResult("添加成功");
	}
	
	/**
	 * 修改物料类型
	* @date 2018年10月9日 上午11:17:16 
	* @author 李斌
	* @return Map<String,Object> 
	* @throws
	 */
	@RequestMapping("/updateCompanyMaterialType")
	@ResponseBody
	public Map<String,Object> updateCompanyMaterialType(HttpServletRequest request){
		Map<String,String> map = RequestUtil.getRequestAllParam(request);
		companyMaterialTypeService.updateCompanyMaterialType(map);
		return ResponseUtil.ResponseResult("修改成功");
	}
}
